package day_2022_7_to_8.day48;

/**
 * @author haomin
 * @date 2022/08/09 11:08
 **/
public class Day24_1_Num1413_MinStartValue {
    class Solution {
        public int minStartValue(int[] nums) {
            int sum = 0,min = Integer.MAX_VALUE;
            for(int num : nums){
                sum += num;
                if(min > sum ) min = sum;  // 找到前缀和最小值
            }
            return min > 0 ? 1 : 1-min;
        }
    }
}